package com.prs.crm.domain.sys;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

@Entity
@Table(name="sys_fieldchoose")
public class FieldChoose extends FieldUIItem{

	private static final long serialVersionUID = 1L;

	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	@OneToMany(mappedBy="parent",fetch = FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<ChooseItem> items;

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setItems(Set<ChooseItem> items) {
		this.items = items;
	}

	public Set<ChooseItem> getItems() {
		return items;
	}
	
	public void addItem(ChooseItem item)
	{
		if (items==null)
			items = new HashSet<ChooseItem>();
		items.add(item);
	}
}
